﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 生成Excel
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            StringBuilder OutFileContent = new StringBuilder();//容器
            //写头文件
            OutFileContent = ExcelHelper.AddHeadFile(OutFileContent);
            //写内容
            StringBuilder sbMsg = new StringBuilder();//容器
            OutFileContent.Append(AddContentFile(sbMsg));
            //写尾文件
            OutFileContent = ExcelHelper.AddEndFile(OutFileContent);
            //保存到xls
            string strRandomFileName = "房客多软件客户";
            string strExcelFile = strRandomFileName + ".xlsx";
            byte[] btArray = new byte[OutFileContent.Length];
            btArray = Encoding.UTF8.GetBytes(OutFileContent.ToString());
            using (FileStream fsWrite = new FileStream(strExcelFile, FileMode.CreateNew))
            {
                fsWrite.Write(btArray, 0, btArray.Length);
            };
        }

        private StringBuilder AddContentFile(StringBuilder OutFileContent)
        {
           
                OutFileContent.Append("<Row ss:AutoFitHeight=\"0\">");
                OutFileContent.Append("<Cell><Data ss:Type=\"String\">报备日期</Data></Cell>");
                OutFileContent.Append("<Cell><Data ss:Type=\"String\">报备楼盘</Data></Cell>");
                OutFileContent.Append("<Cell><Data ss:Type=\"String\">客户姓名</Data></Cell>");
                OutFileContent.Append("<Cell><Data ss:Type=\"String\">客户电话</Data></Cell>");
                // OutFileContent.Append("<Cell><Data ss:Type=\"String\">房产公司</Data></Cell>");
                OutFileContent.Append("<Cell><Data ss:Type=\"String\">所属门店</Data></Cell>");
                OutFileContent.Append("<Cell><Data ss:Type=\"String\">经纪人姓名</Data></Cell>");
                OutFileContent.Append("<Cell><Data ss:Type=\"String\">经纪人电话</Data></Cell>");
                OutFileContent.Append("<Cell><Data ss:Type=\"String\">带看项目</Data></Cell>");
                OutFileContent.Append("<Cell><Data ss:Type=\"String\">带看日期</Data></Cell>");
                OutFileContent.Append("<Cell><Data ss:Type=\"String\">客户状态</Data></Cell>");
                OutFileContent.Append("<Cell><Data ss:Type=\"String\">推送楼盘</Data></Cell>");
                OutFileContent.Append("<Cell><Data ss:Type=\"String\">推送结果</Data></Cell>");
                OutFileContent.Append("<Cell><Data ss:Type=\"String\">备注</Data></Cell>");
                OutFileContent.Append("</Row>");
            return OutFileContent;
        }
    }
}
